package com.wll.design.原型;

/**
 * @author ：wanglulu
 * @date ： 2021/11/12 17:53
 * @description：用户
 * @version: 1.0
 */
public class User implements Cloneable{

    private String name;

    private String address;

    private Integer age;

    public User() {
        System.out.println("User 创建=====》》》》》》");
    }

    /**
     * 重写克隆方法
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        User user = new User();
        user.setName(this.name);
        user.setAddress(this.address);
        user.setAge(this.age);
        return user;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", age=" + age +
                '}';
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return this.name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     *
     * @return address
     */
    public String getAddress() {
        return this.address;
    }

    /**
     * 设置
     *
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     *
     * @return age
     */
    public Integer getAge() {
        return this.age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(Integer age) {
        this.age = age;
    }
}
